package com.tanhua.dubbo.api.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.SoulOptions;
import com.tanhua.dubbo.api.SoulOptionsApi;
import com.tanhua.dubbo.mapper.SoulOptionsMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 选项API实现
 */
@Service
public class SoulOptionsApiImpl implements SoulOptionsApi {

	@Autowired
	private SoulOptionsMapper soulOptionsMapper;

	/**
	 * 根据试题id查询对应的所有选项
	 */
	@Override
	public List<SoulOptions> findByQuestionId(Long id) {
		QueryWrapper<SoulOptions> wrapper = new QueryWrapper<>();
		wrapper.eq("question_id",id);
		return soulOptionsMapper.selectList(wrapper);
	}

	/**
	 * 根据试题id和选项id获取选项
	 */
	@Override
	public SoulOptions findByQuestionIdAndOptionId(Long questionId, String optionId) {
		QueryWrapper<SoulOptions> wrapper = new QueryWrapper<>();
		wrapper.eq("question_id",questionId).eq("id",optionId);
		return soulOptionsMapper.selectOne(wrapper);
	}
}
